﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using DECOR.BL.BE;

namespace DECOR.Touchapp
{
    public partial class crearReclamo : System.Web.UI.Page
    {
        string pRetval = "";
        string fechaI = "";
        string horaReclamoI = "";
        string fechaF = "";
        string horaReclamoF = "";
        string fechaSts = "";
        string codigoEmpResp = ""; //es el codigo de usuario
        string nombreEmpResp = ""; //es el nombre del usuario 

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Request.HttpMethod.Equals("POST"))
            {

            }
            else
            {
                pRetval = "{\"success\": {0}, \"errors\":{\"reason\": \"{1}\"}, ";

                pRetval += "\"reclamo\": [{";

                pRetval += "\"fechaI\": \"{2}\", \"horaReclamoI\": \"{3}\", ";
                pRetval += "\"fechaF\": \"{4}\", \"horaReclamoF\": \"{5}\", ";
                pRetval += "\"fechaSts\": \"{6}\", \"codigoEmpResp\": \"{7}\", ";
                pRetval += "\"nombreEmpResp\": \"{8}\" ";
                pRetval += "}";
                pRetval += "]}";

                CargarReclamo();

                Response.ContentType = "application/json; charset=UTF-8";
                Response.Write(pRetval);
            }
        }

        private void CargarReclamo()
        {
            fechaI = DateTime.Today.ToString("dd/MM/yyyy");
            horaReclamoI = DateTime.Now.TimeOfDay.ToString().Substring(0, 8);
            fechaF = DateTime.Today.ToString("dd/MM/yyyy");
            horaReclamoF = DateTime.Now.TimeOfDay.ToString().Substring(0, 8);
            fechaSts = DateTime.Today.ToString("dd/MM/yyyy");
            codigoEmpResp = Request.Params["CodigoVendedor"];
            nombreEmpResp = Request.Params["Descripcion"];

            pRetval = pRetval.Replace("{0}", "true");
            pRetval = pRetval.Replace("{1}", "");
            pRetval = pRetval.Replace("{2}", fechaI);
            pRetval = pRetval.Replace("{3}", horaReclamoI);
            pRetval = pRetval.Replace("{4}", fechaF);
            pRetval = pRetval.Replace("{5}", horaReclamoF);
            pRetval = pRetval.Replace("{6}", fechaSts);
            pRetval = pRetval.Replace("{7}", codigoEmpResp);
            pRetval = pRetval.Replace("{8}", nombreEmpResp);

        }
    }
}